﻿using System;
using System.Data;
using Model.Data;
using Model;
using DataAccess;
using BusinessLogic.BusinessRules;


namespace BusinessLogic.ClassFactory
{
    /// <summary>
    /// LinksGroupFactory 的摘要说明。
    /// </summary>
    public class LinksGroupFactory : BaseFactory
    {
        public LinksGroupFactory()
            : base()
        {
            //
            // TODO: 在此处添加构造函数逻辑
            //
        }
        public LinksGroupFactory(DBManager l_DBManager)
            : base(l_DBManager)
        {
        }
        public LinksGroup NewInstance()
        {
            LinksGroupAccess l_Access = new LinksGroupAccess(m_Manager);
            LinksGroup objLinksGroup = new LinksGroup(this.m_Manager, l_Access);
            objLinksGroup.NewDataSet();
            objLinksGroup.SelectRow(0);
            return objLinksGroup;
        }

        public LinksGroup CreatorBySql(string Sql)
        {
            LinksGroupAccess l_Access = new LinksGroupAccess(m_Manager);
            LinksGroup objLinksGroup = new LinksGroup(this.m_Manager, l_Access);
            DataSet l_ds = new LinksGroupData();
            if (l_Access.QueryBySql(ref l_ds, Sql) < 1)
            {
                return null;
            }
            objLinksGroup.SetDataSet(l_ds);
            objLinksGroup.SelectRow(0);
            return objLinksGroup;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="intGroupID"></param>
        /// <returns></returns>
        public LinksGroup Creator(int intGroupID)
        {
            LinksGroupAccess l_Access = new LinksGroupAccess(m_Manager);
            LinksGroup objLinksGroup = new LinksGroup(this.m_Manager, l_Access);
            DataSet l_ds = new LinksGroupData();
            if (l_Access.QueryByID(ref l_ds, intGroupID) < 1)
            {
                return null;
            }
            objLinksGroup.SetDataSet(l_ds);
            objLinksGroup.SelectRow(0);
            return objLinksGroup;
        }

        public LinksGroup Creator()
        {
            LinksGroupAccess l_Access = new LinksGroupAccess(m_Manager);
            LinksGroup objLinksGroup = new LinksGroup(this.m_Manager, l_Access);
            DataSet l_ds = new LinksGroupData();
            if (l_Access.QueryAll(ref l_ds) < 1)
            {
                return null;

            }
            objLinksGroup.SetDataSet(l_ds);
            objLinksGroup.SelectRow(0);
            return objLinksGroup;
        }

        public int Delete(int intGroupID)
        {
            LinksGroupAccess l_Access = new LinksGroupAccess(m_Manager);
            return l_Access.Delete(intGroupID);
        }
        public int DeleteWhere(string where)
        {
            LinksGroupAccess l_Access = new LinksGroupAccess(m_Manager);
            return l_Access.DeleteWhere(where);
        }
    }
}
